//
//  Tile.h
//  Mockup
//
//  Created by Bernardo Quibiana on 2/20/10.
//  Copyright 2010 Mac-Easy@USC. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Utils.h"


@interface Tile : NSObject {
	tile_t type;
	struct point_t pos;
	
	CGPoint initial;
	CGPoint final;
	BOOL falling;
	BOOL ascending;
	
	IBOutlet UIView * containerView;
	IBOutlet UIImageView * mainImage;
	IBOutlet UIImageView * backImage;
}

@property (nonatomic) tile_t type;
@property (nonatomic) struct point_t pos;
@property (nonatomic, retain) IBOutlet UIView * containerView;
@property (nonatomic, retain) IBOutlet UIImageView * mainImage;
@property (nonatomic, retain) IBOutlet UIImageView * backImage;

// initializers
//-(id) initWithPosition: (struct point_t) _pos andImage: (UIImageView *) _image;
-(id) initWithPosition: (struct point_t) _pos andType: (tile_t) _type;
//-(id) initWithPosition: (struct point_t) _pos andImage: (UIImageView *) _image andType: (tile_t) _type;

-(void) updateImagePos;
-(void) updateImage;
-(void) switchToType: (tile_t) newType;

-(struct point_t) viewToGridCoord;
-(struct point_t) viewToGridCoord:(CGPoint) viewPosition;
-(CGPoint) gridToViewCoord:(struct point_t) gridPosition;

// animations
-(void) animateFlipToTile: (tile_t) _type onDirection: (direction_t) direction;
-(void) shiftWithOffset:(double) offset onDirection:(direction_t) direction;

-(void) adjustPosition;
-(CGPoint) findAdjustedPosition;
-(struct point_t) getCurBoardPosition;

-(void) moveUp:(BOOL) animated;
-(void) moveDown: (BOOL) animated;
-(void) moveOnDirection: (direction_t) direction animated:(BOOL) animated;
-(void) timedMoveUp:(NSTimer *) timer;
-(void) timedMoveDown: (NSTimer *) timer;

-(void) animatePoofWithDelay:(NSTimeInterval) delay;
-(void) startPoofAnimation;
-(void) stopPoofAnimation;

// matching
-(BOOL) checkMatch:(Tile *) _tile;

// image picker
+(UIImage *) imageForTileType: (tile_t) _type;
+(NSArray *) poofAnimationImages;

// to match
+(BOOL) chechMatch:(Tile *) lTile :(Tile *) rTile;

@end

	